<template>
  <div>
    <el-breadcrumb separator="/">
      <el-breadcrumb-item>考勤管理</el-breadcrumb-item>
      <el-breadcrumb-item>上班打卡</el-breadcrumb-item>
    </el-breadcrumb>

    <el-row class="margintop20">
      <el-col :span="10" class="margintop20">
        <el-form :model="form" :rules="rules" ref="myForm" label-width="100px" class="myform">
          <el-form-item label="姓名：" prop="username">
            <el-input v-model="form.username" disabled></el-input>
          </el-form-item>
          <el-form-item label="电话号：" prop="mobile">
            <el-input v-model="form.mobile" disabled></el-input>
          </el-form-item>

          <el-form-item label="打卡时间：" prop="time1">
            <el-col :span="11">
              <el-date-picker
                type="date"
                placeholder="选择日期"
                v-model="form.time"
                style="width: 100%;"
              ></el-date-picker>
            </el-col>
          </el-form-item>
          <el-form-item>
            <el-button type="info" class="width100" @click="addForm">打卡</el-button>
          </el-form-item>
        </el-form>
      </el-col>
    </el-row>
  </div>
</template>

<script>
import { adddaka } from "@/api";
export default {
  data() {
    return {
      form: {
        username: sessionStorage.getItem("username"),
        mobile: localStorage.getItem("mobile"),
      },
      rules: {
        time: [
          { required: true, message: "请选择入职时间", trigger: "change" },
        ],
      },
    };
  },
  methods: {
    addForm() {
      this.$refs.myForm.validate((valid) => {
        if (valid) {
          adddaka(this.form).then((res) => {
            if (res.type) {
              console.log();
              this.$router.push({ name: "moneychecks" });
            }
          });
        }else{
          this.$message.error('请输入完整....')
        }
      });
    },
    resetFrom() {},
  },
};
</script>